import { isMobile } from '@/utils/isMobile'

export const deviceWidth = () : number => {
  if (isMobile.any()) {
    return document.documentElement.clientWidth
  }
  return 500
}
export default function (deviceWidth: number) :void{
  console.log(deviceWidth, 'deviceWidth')

  document.documentElement.style.fontSize = deviceWidth * (32 / 750) + 'px'

  // 禁止双击放大
  document.documentElement.addEventListener('touchstart', function (event) {
    if (event.touches.length > 1) {
      event.preventDefault()
    }
  }, false)
  let lastTouchEnd = 0
  document.documentElement.addEventListener('touchend', function (event) {
    const now = Date.now()
    if (now - lastTouchEnd <= 300) {
      event.preventDefault()
    }
    lastTouchEnd = now
  }, false)
}
